import { request, BaseResponse } from '@/utils/request';
/**
 * @description 元数据管理
 * @param {Namespace} isMock
 * @param isGetDataDirectly
 * @returns
 */
/**
 * 获取表格数据
 */

export function getDatalist(query: string) {
  return request<BaseResponse<Array<Namespace.tableData>>>(
    {
      url: `/sys/parameter/getdatalist/${query}`,
      method: 'get',
    },
    {
      isMock: false,
      isGetDataDirectly: false,
    },
  );
}
export function getDatalistEnum(query: string) {
  return request<BaseResponse<Array<Namespace.tableDataEnum>>>(
    {
      url: `/sys/parameter/getdatalist/${query}`,
      method: 'get',
    },
    {
      isMock: false,
      isGetDataDirectly: false,
    },
  );
}
/**
 * 刷新数据
 * @param data ID
 * @returns Array
 */
export function refreshDataList(data: { id: string }) {
  return request<BaseResponse>(
    {
      url: `/sys/parameter/uptablefield`,
      method: 'post',
      data,
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    },
    {
      isMock: false,
      isGetDataDirectly: false,
      successMsg: '刷新成功',
    },
  );
}

/**
 * 批量删除数据
 * @param data ID
 * @returns Array
 */

export function deleteTableList(data: Array<number>) {
  return request<BaseResponse>(
    {
      url: `/sys/parameter/batchremove`,
      method: 'post',
      data,
    },
    {
      isMock: false,
      isGetDataDirectly: false,
      successMsg: '删除成功',
    },
  );
}

/**
 * 批量保存数据
 * @param data ID
 * @returns Array
 */

export function saveData(data: String) {
  return request<BaseResponse>(
    {
      url: `/sys/parameter/batchsave`,
      method: 'post',
      data,
      headers: { 'Content-Type': 'application/json' },
    },
    {
      isMock: false,
      isGetDataDirectly: false,
      successMsg: '提交成功',
    },
  );
}

/**
 * 枚举获取多语言
 * @param languageType id
 */

export function getMultipleLanguages(id: String, languageType: String) {
  return request<BaseResponse>(
    {
      url: `/sys/unit/updatelanguageenum`,
      method: 'post',
      data: {
        id,
        languageType,
      },
      headers: { 'Content-Type': 'application/json' },
    },
    {
      isMock: false,
      isGetDataDirectly: false,
      successMsg: '加载成功',
    },
  );
}
